//
//  TOBaseNavigationController.m
//  SeaGullFM
//
//  Created by dllo on 15/12/1.
//  Copyright © 2015年 tianou. All rights reserved.
//

#import "WSBaseNavigationController.h"

@interface WSBaseNavigationController ()

@end

@implementation WSBaseNavigationController

-(instancetype)initWithRootViewController:(UIViewController *)rootViewController
{
    if (self = [super initWithRootViewController:rootViewController]) {
        
        if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"Mode"] isEqualToString:@"night"]) {
            [self.navigationBar setBackgroundImage:NAVBAR_IMAGE_NIGHT forBarMetrics:UIBarMetricsDefault];
        }
        else
        {
            [self.navigationBar setBackgroundImage:NAVBAR_IMAGE_DAY forBarMetrics:UIBarMetricsDefault];

        }
        
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor:) name:@"changeColor" object:nil];
    }
    
    return self;
}

-(void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"changeColor" object:nil];
}
-(void)changeColor:(NSNotification *)notifition
{
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"Mode"] isEqualToString:@"night"])
    {
        [self.navigationBar setBackgroundImage:NAVBAR_IMAGE_NIGHT forBarMetrics:UIBarMetricsDefault];

        
    }
    else
    {
        [self.navigationBar setBackgroundImage:NAVBAR_IMAGE_DAY forBarMetrics:UIBarMetricsDefault];

    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
